<extend name="Public/base" />

<block name="body"> <script type="text/javascript"
                            src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>

    <div class="main-title">
        <h2>{:isset($info['id'])?'编辑':'新增'}轮播图</h2>
    </div>
    <div class="tab-wrap">
        <form action="{$self}" method="post" class="form-horizontal">
            <input type="hidden" name="id" value="{$info.id}">
            <div class="form-item">
                <label class="item-label">标题<span class="check-tips">（不能为空）</span></label>
                <div class="controls">
                    <input type="text" class="text input-large" name="title" value="{$info.title}">
                    <input type="hidden" value="index_banner" name="position">
                </div>
            </div>
            <div class="form-item">
                <label class="item-label">排序<span class="check-tips">数字越小越靠前</span></label>
                <div class="controls">
                    <input name="sort" value="{$info.sort|default=0}" class="text input-small" />
                </div>
            </div>

            <div class="form-item">
                <label class="item-label">跳转链接<span class="check-tips"></span></label>
                <div class="controls">
                    <label class="radio"><input type="radio" name="type" value="1" {$check1}>外链接</label>
                    <label class="radio"><input type="radio" name="type" value="0"{$check2}>内链接</label>
                </div>
            </div>

            <div class="form-item" style="position:relative;z-index:5555;">
                <label class="item-label">外链接</label>
                <div class="controls no-overview">
                    <input type="text" class="text input-large" name="url" value="{$info.url}">
                </div>
            </div>
            <div class="form-item">
                <label class="item-label">轮播图片<span class="check-tips">建议图片尺寸（750*330）</span></label>
                <div class="controls">
                    <input type="file" id="upload_picture_file">
                    <input type="hidden" name="cover_id" id="cover_id" value="{$info.cover_id}" />
                    <div class="upload-img-box">
                        <notempty name="info.cover_id">
                            <div class="upload-pre-item">
                                <img src="__ROOT__{$info.cover_id|get_cover='path'}" /><span class="btn-close" title="删除图片" onclick="$(this).parent().remove();"></span>
                            </div>
                        </notempty>
                    </div>
                </div>
                <script type="text/javascript">
                    $("#upload_picture_file").uploadify({
                        "height"          : 30,
                        "swf"             : "__STATIC__/uploadify/uploadify.swf",
                        "fileObjName"     : "download",
                        "buttonText"      : "上传图片",
                        "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
                        "width"           : 120,
                        'removeTimeout'	  : 1,
                        'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
                        "onUploadSuccess" : uploadPicture_panel,
                        'onFallback' : function() {
                            alert('未检测到兼容版本的Flash.');
                        }
                    });
                    function uploadPicture_panel(file, data){
                        var data = $.parseJSON(data);
                        var src = '';
                        if(data.status){
                            $("#cover_id").val(data.id);
                            src = data.url || '__ROOT__' + data.path
                            $("#cover_id").parent().find('.upload-img-box').html(
                                    '<div class="upload-pre-item"><img src=" ' + src + '"/></div>'
                            );
                        } else {
                            updateAlert(data.info);
                            setTimeout(function(){
                                $('#top-alert').find('button').click();
                                $(that).removeClass('disabled').prop('disabled',false);
                            },1500);
                        }
                    }
                </script>
            </div>



            <div class="form-item" >
                <label class="item-label">详细内容</label>
                <div class="controls no-overview">
                    <textarea name="content">{$info.content}</textarea>
                    {:hook('adminArticleEdit', array('name'=>'content','value'=>$config.content))}
                </div>
            </div>

            <div class="form-item">
                <button class="btn submit-btn ajax-post" id="submit" type="submit" target-form="form-horizontal">保存</button>
                <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
            </div>
        </form>
    </div>
</block>

<block name="script">
    <link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
    <php>if(C('COLOR_STYLE')=='blue_color') echo '<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';</php>
    <script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
    <script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
    <link rel="stylesheet" type="text/css" href="__STATIC__/bootstrap/css/bootstrap-select.css" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/bootstrap/css/bootstrap-typeahead.css" />
    <script type="text/javascript" src="__STATIC__/bootstrap/js/bootstrap.js"></script>
    <script type="text/javascript" src="__STATIC__/bootstrap/js/bootstrap-select.js"></script>
    <script type="text/javascript" src="__STATIC__/bootstrap/js/bootstrap-typeahead.js"></script>
    <script type="text/javascript" charset="utf-8">
        highlight_subnav('{:U('Ad/lunbo')}');
        $(function(){
            //日期时间选择器
            $("#begin_time").datetimepicker({
                format: "yyyy-mm-dd",
                autoclose: true,
                minView: "month",
                maxView: "decade",
                todayBtn: true,
                pickerPosition: "bottom-left"
            }).on("click",function(ev){
                $("#begin_time").datetimepicker("setEndDate", $("#end_time").val());
            });

            $("#end_time").datetimepicker({
                format: "yyyy-mm-dd",
                autoclose: true,
                minView: "month",
                maxView: "decade",
                todayBtn: true,
                pickerPosition: "bottom-left"
            }).on("click", function (ev) {
                $("#end_time").datetimepicker("setStartDate", $("#begin_time").val());
            });
        });
    </script>
</block>
